package com.da.lon.wang.xlg.util;

import android.os.Handler;
import android.util.Log;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;

public class JavaScriptExit {

    private WebView webView;

    public JavaScriptExit(WebView webView) {
        this.webView = webView;

        Log.i("aaaa", "create DemoJavaScriptInterface");
    }

    @JavascriptInterface
    public void clickOnAndroid(final int type, final String content) {
        new Handler().post(new Runnable() {
            public void run() {
                switch (type) {
                    case 1:
                        webView.loadUrl("javascript:yijian_show('" + content + "')");
                        break;
                    case 2:
                        webView.loadUrl("javascript:tuikuan_show('" + content + "')");
                        break;
                    case 3:
                        webView.loadUrl("javascript:" + content);
                    case 4:
                        //收藏取消了，返回刷新页面
                        webView.loadUrl("javascript:backReload()");
                        break;
                    default:
                        break;
                }


            }
        });
    }
}
